﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using WeifenLuo.WinFormsUI.Docking;

using Plugin;
using StandardFramework;
using DependencyInjection;
using PolarExpress.View.Interfaces;
using PolarExpress.Model.Interfaces;

namespace PolarExpress.View
{
    public partial class FrmExplorerView : DockContent, IExplorerView
    {
        IProject _project;

        [Inject]
        public FrmExplorerView(IProject project)
        {
            InitializeComponent();

            _project = project;
            _project.ModelChanged += new ModelChangedHandler(_project_ModelChanged);
        }

        void _project_ModelChanged(object sender, ModelChangedEventArgs args)
        {
            treeView1.BeginUpdate();

            treeView1.Nodes.Clear();

            foreach (BaseComponent component in _project.ComponentPool)
            {
                treeView1.Nodes.Add(component.Name);
            }

            treeView1.EndUpdate();
        }
    }
}
